<?php
/**
 * Created by PhpStorm.
 * User: lizx
 * Date: 2018/1/30
 * Time: 9:54
 */

namespace app\common\Server;

use think\Config;

class Redis extends \think\cache\driver\Redis
{

    static $_instance = [];

    public function __construct()
    {
        $options = Config::get('redis');
        parent::__construct($options);
    }

    /**
     * 创建实例
     * @param bool $flush
     * @return mixed
     */
    public function getInstance($flush = 0)
    {
        if ($flush || empty(self::$_instance)) {
            self::$_instance = $this->handler();
        }
        return self::$_instance;
    }
}

